//
//  BaseTableViewController.swift
//  微博天下

import UIKit
class BaseTableViewController: UITableViewController ,VisitorLoginViewDelegate{
    
    //用户登录成功标记
    var userLogin = false
    //设置访客试图
    var visitorView:TSZVisitorLoginView?
    
    
   //这个方法是加载view的时候调用
    override func loadView() {
        TSZUserAcountModel.userLogin ?super.loadView() :setupVisitorLoginView()
    }
    
    //设置访客试图
    private func setupVisitorLoginView(){
        visitorView = TSZVisitorLoginView()
        //代理
        visitorView?.delegate = self
        view = visitorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
    }
    
    // MARK: - VisitorLoginViewDelegate
    /// 用户登录
    func visitorLoginViewWillLogin() {
        let nav = UINavigationController(rootViewController: TSZOAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
        let nav = UINavigationController(rootViewController: TSZOAuthViewController())
        
        presentViewController(nav, animated: true, completion: nil)
    }
}
